package com.qf.hospital.system.mapper;

import com.qf.hospital.system.entity.SysRole;
import com.qf.hospital.system.entity.SysUser;
import com.qf.hospital.system.vo.SideTreeVO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface SysUserMapper {
    int deleteByPrimaryKey(Integer userId);

    int insert(SysUser record);

    int insertSelective(SysUser record);

    SysUser selectByPrimaryKey(Integer userId);

    int updateByPrimaryKeySelective(SysUser record);

    int updateByPrimaryKey(SysUser record);

    @Select(value = "select * from sys_user where login_name = #{username} and available = 1")
    SysUser findByUsername(@Param("username") String username);

    // 查询侧边栏
    List<SideTreeVO> findMenuByUserId(@Param("userId") Integer userId);

    // 查询用户信息
    List<SysUser> findSysUserByCondition(SysUser sysUser);

    // 查询全部角色信息
    List<SysRole> findAllSysRole();


    // 删除当前用户的全部角色信息
    void deleteUserRolesByUserId(@Param("userId")Integer userId);

    // 批量添加用户的角色信息
    void insertUserRoles(@Param("userId")Integer userId,@Param("ids")Integer[] ids);

    // 查询当前userid用户拥有的角色信息
    List<SysRole> findUserRoleByUserId(@Param("userId") Integer userid);
}